import sys, pygame
from pygame.locals import *

size = width, height = 640, 480
fade_fps = 25
fade_delay = 1000 / fade_fps
white = [255, 255, 255]

alpha = 0

screen = pygame.display.set_mode(size)

image = pygame.image.load("data/powered.png")
image_rect = image.get_rect()
image_rect.topleft = (0, 0)

while 1:
	screen.fill(white)
	screen.set_alpha(alpha)
	screen.blit(image, image_rect)
	pygame.display.flip()
	pygame.time.delay(fade_delay)
	
	alpha += 1
	
	if alpha == 255:
		break

while 1:
	screen.fill(white)
	screen.set_alpha(alpha)
	screen.blit(image, image_rect)
	pygame.display.flip()
	pygame.time.delay(fade_delay)
	
	alpha -= 1
	
	if alpha == 0:
		break

event = pygame.event.poll()
if (event.type == KEYDOWN and event.key == K_ESCAPE):
	sys.exit()

	
	